 import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_html/flutter_html.dart';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:magic_car/util/HttpHelper.dart';
import 'package:magic_car/util/config.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:webview_flutter/webview_flutter.dart';

class GurateenAgreementPage extends StatefulWidget {
  GurateenAgreementPage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<GurateenAgreementPage> {
  var content = '';
  Map acountinfo = new Map();
  @override
  void initState() {
    super.initState();

    loaddata();
  }

  //加载数据
  loaddata() async {
    EasyLoading.show(status: "加载中...");
    Map<String, String> map = new Map();
    SharedPreferences pref = await SharedPreferences.getInstance();
    map["type"] = pref.getString('role');
    HttpHelper.post(HttpHelper.API_Gurateen_product, (data) async {
      EasyLoading.dismiss();
      print(data);
      if (data != null) {
        print(data);

        if (data["code"].toString() == "1") {
          setState(() {
          
           content = data['info']['xieyi'];
          });
        }
      }
    }, params: map);
  }

  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          titleSpacing: 0,
          title: new Text('保修服务说明',style: TextStyle(fontSize: Config.title_size),),
          backgroundColor: Colors.white,
          elevation: 0,
        ),
        body: new Container(
            child: new ListView(children: <Widget>[
              content==""?Container(height: 0,):CachedNetworkImage(imageUrl: content)
            //  content==""?Container(height: 0,): WebView(initialUrl: content,)

          // WebView(

          //       )
          // Html(
          //   data: content,
          // ),
        ])));
  }
}
